package com.luyuan.crm.user.web;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.faces.model.SelectItem;

import org.springframework.stereotype.Component;

import com.ruijie.components.security.model.Role;
import com.ruijie.components.security.service.RoleService;
import com.ruijie.web.jsf.provider.SelectItemsProvider;

@Component("roleProvider")
public class RoleProvider implements SelectItemsProvider {
    @Resource(name = "roleService")
    private RoleService roleService;

    @Override
    public List<SelectItem> getSelectItems(Object... parameters) {
        List<Role> roles = roleService.getAllRoles();

        List<SelectItem> items = new ArrayList<SelectItem>();
        for (Role role : roles) {
            if ("会员".equals(role.getRoleName())) {
                continue;
            }

            SelectItem item = new SelectItem(role.getId(), role.getRoleName());
            items.add(item);
        }
        return items;
    }

}
